#include <string.h>
#include <jni.h>
#include <android/log.h>

extern "C" {
jstring  Java_com_example_ilewis_hello_HelloMain_foo (JNIEnv* env,
    jobject thiz);
}

jstring  Java_com_example_ilewis_hello_HelloMain_foo (JNIEnv* env,
    jobject thiz) {
  __android_log_print(ANDROID_LOG_INFO, "hello", "howdy");

  jclass c = env->FindClass("com/example/ilewis/hello/HelloMain");
  if(c==NULL) {
    __android_log_print(ANDROID_LOG_INFO, "hello", "findclass failed");
  }
  jmethodID m = env->GetMethodID(c, "SetText", "(Ljava/lang/String;)V");
  if (m==NULL) {
    __android_log_print(ANDROID_LOG_INFO, "hello", "getmethodid failed");
  }

  jstring s = env->NewStringUTF("hello");
  jstring s2 = env->NewStringUTF("another visitor. stay a while. STAY FOREVER!!");

  env->CallVoidMethod(thiz,m,s2);

  return s;

}
